<template>
  <div style="background-color: #000;">
    <div v-if="informationList.length != '0'">
      <div class="countent" v-loading="loading" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading"
        element-loading-background="rgba(255, 255, 255, 0.8)">
        <div v-for="item in informationList" :key="item.time" class="block">
          <div class="type">{{item.title}}</div>
          <div class="time">{{item.mtime}}</div>
          <div class="text">{{item.content}}</div>
          <div class="new" v-if="item.unread == 1">未读<span class="dot"></span></div>
        </div>
        <div class="pagination" v-show="!loading" v-if="informationList.length != '0'">
          <el-pagination small :page-size="pagesize" background layout="prev, pager, next" :total="total"
            @current-change="currentchange">
          </el-pagination>
        </div>
      </div>
    </div>
    <div v-else class="noinformation">
      <p><i class="el-icon-close-notification"></i>没有信息</p>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        informationList: [],
        loading: true,
        total: 0, //页码的总数
        pagesize: 10, //单页显示的条数
        currentPage: 1, //当前的页码
      }
    },
    methods: {
      query() {
        this.loading = true
        var that = this;
        let params = new URLSearchParams();
        params.append('pageNum', this.currentPage);
        params.append('pageSize', this.pagesize);
        this.$post(this.API.getInformationList, params).then(res => {
          this.loading = false
          let data = res.data;
          this.informationList = data.list;
          this.total = data.count;
        });
      },
      currentchange(newpage) {
        this.currentPage = newpage;
        this.query();
      }
    },
    created() {
      this.query();
    }
  }

</script>
<style scoped>
  .countent {
    width: 100%;
    min-height: 50px;
    padding: 30px 35px 30px 40px;
    background-color: #0f0f0f;
  }

  .countent>>>.el-loading-spinner i {
    color: #FF7226;
  }

  .countent>>>.el-loading-spinner .el-loading-text {
    color: #FF7226;
  }

  .pagination {
    width: 100%;
    text-align: center;
  }

  div>>>.el-pagination.is-background .el-pager li:not(.disabled).active {
    background-color: #FF7226 !important;
    color: #FFF;
  }

  div>>>.el-pagination.is-background .el-pager li:not(.disabled):hover {
    color: #FF7226;
  }

  div>>>div[data-v-4dc1f2ac] .el-pagination.is-background .el-pager li:not(.disabled).active {
    background-color: #FF7226 !important;
    color: #fff;
  }

  .block {
    margin-bottom: 30px;
    background-color: #272727;
    border-radius: 8px;
    padding: 20px 15px 20px 30px;
    position: relative;
  }

  .type {
    color: #fff;
    display: inline-block;
    text-align: left;
    width: 200px;
    font-weight: 600;
    font-size: 16px;
    line-height: 30px;
  }

  .time {
    color: #fff;
    display: inline-block;
    text-align: left;
    width: 200px;
    font-size: 16px;
    font-weight: 600;
    line-height: 30px;
  }

  .text {
    color: #999;
    width: 750px;
    font-size: 14px;
    font-weight: 400;
    line-height: 30px;
  }

  .new {
    position: absolute;
    right: 15px;
    top: calc(50% - 30px);
    color: #FFF;
  }

  .dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    background-color: #FF7226;
    border-radius: 50%;
    margin-left: 5px;
    margin-top: 3px;
  }

  .noinformation {
    width: 100%;
    height: 200px;
    text-align: center;
    color: #fff;
    font-size: 18px;
    padding-top: 60px;
    background-color: #0f0f0f;
  }

  .el-icon-s-comment {
    font-size: 16px;
    margin-right: 5px;
  }

</style>
